package com.hws.leetcode.Day_01_03;

import java.util.ArrayList;
import java.util.List;

/**
 * ClassName:leetcode_1185
 * Package:com.hws.leetcode.Day_01_03
 * Description:
 *
 * @ date:2022/1/3 20:46
 * @ author:hws
 */
public class leetcode_1185 {


    //蔡勒公式（日期->星期）
    static String[] ss = new String[]{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
    static int[] nums = new int[]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    public String dayOfTheWeek(int day, int month, int year) {
        int ans = 4;
        for (int i = 1971; i < year; i++) {
            ans += 365;
            if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0) {
                ans++;
            }
        }
        for (int i = 1; i < month; i++) {
            if (((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) && i == 2) {
                ans++;
            }
            ans += nums[i - 1];
        }
        ans += day;
        return ss[ans % 7];
    }

    public static void main(String[] args) {
        leetcode_1185 lc = new leetcode_1185();
        System.out.println(lc.dayOfTheWeek(21, 12, 1980));
    }

}
